<template>
    <div class="componentChild">
        <button @click="handleClick">打印</button>
    </div>
</template>

<!-- 通过defineEmits向父类传递数据 -->
<script setup lang="ts">
type Emits = {
    (evt: 'msg', info: string | number): void
}

const emit = defineEmits<Emits>()
const handleClick = () => {
    // Emits 类型定死了evt只能写msg
    emit('msg', 'test string')
}
</script>

<style scoped></style>